
package com.shop.cloud.mall.api.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cloud.common.core.constant.CacheConstants;
import com.shop.cloud.mall.common.entity.UserGradeConfig;
import com.shop.cloud.mall.api.mapper.UserGradeConfigMapper;
import com.shop.cloud.mall.api.service.UserGradeConfigService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 用户等级配置
 *
 * @author
 * @date 2023-03-15 14:13:46
 */
@Service
public class UserGradeConfigServiceImpl extends ServiceImpl<UserGradeConfigMapper, UserGradeConfig> implements UserGradeConfigService {

	@Override
	@Cacheable(value = CacheConstants.MALL_USERGRADE_CONFIG_CACHE, key = "#grade", unless = "#result == null")
	public UserGradeConfig getByGrade(Integer grade) {
		return baseMapper.selectOne(Wrappers.<UserGradeConfig>lambdaQuery()
				.eq(UserGradeConfig::getGrade, grade));
	}
}
